import Request from '@/utils/request'
import Cookies from '@/utils/auth'
const state = () => ({
	editIncentivePolicy:true
})
const getters = {
	
}
const mutations = {
	set_adAnalys: (state, obj) => {
		Object.assign(state.adAnalys,obj)
	}
}
const actions = {
     // 查询客户列表
    async get_customer_list({commit}, params) {
		return new Promise((resolve,reject)=>{
			Request.post('/api/customer/listPage',params)
			.then(res=>{
				resolve(res.data) 
			})
		})
	},
  // 查询客户列表-添加
  async add_customer_list({commit}, params) {
	return new Promise((resolve,reject)=>{
		Request.post('/api/customer/add',params)
		.then(res=>{
			resolve(res.data) 
		})
	})
  },
 // 查询客户列表-删除
 async del_customer_list({commit}, customerId) {
    return new Promise((resolve,reject)=>{
        Request.get(`/api/customer/delete/${customerId}`)
        .then(res=>{
            resolve(res.data) 
        })
    })
   },
	// 投放管理列表
	async get_release_list({commit}, params) {
		return new Promise((resolve,reject)=>{
			Request.post('/api/adPlace/listPageAdPlaceMerchant',params)
			.then(res=>{
				resolve(res.data) 
			})
		})
	},
	// 投放管理列表-取消申请
	async delete_apply_adplacejob({commit}, params) {
		return new Promise((resolve,reject)=>{
			Request.post('/api/adPlaceJob/deleteApplyAdPlaceJob',params)
			.then(res=>{
				resolve(res.data) 
			})
		})
	},
	// 投放管理列表-申请和一键申请
	async batch_apply_adplacejob({commit}, params) {
		return new Promise((resolve,reject)=>{
			Request.post('/api/adPlaceJob/batchApplyOnlineAdPlaceJob',params)
			.then(res=>{
				resolve(res.data) 
			})
		})
	},

		// 投放管理列表-申请单个
	async apply_adplacejob({commit}, params) {
			return new Promise((resolve,reject)=>{
				Request.post('/api/adPlaceJob/applyOnlineAdPlaceJob',params)
				.then(res=>{
					resolve(res.data) 
				})
			})
		},
	
		// 投放管理列表-一键取消
	async batch_delete_adplacejob({commit}, params) {
			return new Promise((resolve,reject)=>{
				Request.post('/api/adPlaceJob/batchDeleteApplyAdPlaceJob',params)
				.then(res=>{
					resolve(res.data) 
				})
			})
		},

	// 投放管理列表-一键暂停
	async stopAdPlaceJobRecord({commit}, params) {
		return new Promise((resolve,reject)=>{
			Request.post('/api/adPlaceJob/stopAdPlaceJobRecord',params)
			.then(res=>{
				resolve(res.data) 
			})
		})
	},
	// 投放管理列表-一键终止
	async offLineAdPlaceJobRecord({commit}, params) {
		return new Promise((resolve,reject)=>{
			Request.post('/api/adPlaceJob/offLineAdPlaceJobRecord',params)
			.then(res=>{
				resolve(res.data) 
			})
		})
	},
	// 投放管理列表-一键恢复
	async recoverAdPlaceJobRecord({commit}, params) {
		return new Promise((resolve,reject)=>{
			Request.post('/api/adPlaceJob/recoverAdPlaceJobRecord',params)
			.then(res=>{
				resolve(res.data) 
			})
		})
	},
	// 投放管理列表-继续申请
	async againApplyAdPlaceJob({commit}, params) {
		return new Promise((resolve,reject)=>{
			Request.post('/api/adPlace/againApplyAdPlaceJob',params)
			.then(res=>{
				resolve(res.data) 
			})
		})
	},
// 投放管理列表-客户下拉列表
async selectCustomer({commit}, params) {
	return new Promise((resolve,reject)=>{
		Request.post('/api/customer/listOption',params)
		.then(res=>{
			resolve(res.data) 
		})
	})
},

 // 查询客户列表-获取广告位内容
 async getPlaceContent({commit}, placeJobId) {
    return new Promise((resolve,reject)=>{
        Request.get(`/api/adPlace/getPlaceContent/${placeJobId}`)
        .then(res=>{
            resolve(res.data) 
        })
    })
   },

 // 查询客户列表-设置（修改）广告位内容
 async changePlaceContent({commit}, params) {
    return new Promise((resolve,reject)=>{
        Request.post(`/api/adPlace/changePlaceContent`,params)
        .then(res=>{
            resolve(res.data) 
        })
    })
   },
 // 查询客户列表-设置（修改）广告位奖励规则
 async changePlaceRewardRule({commit}, params) {
    return new Promise((resolve,reject)=>{
        Request.post(`/api/adPlace/changePlaceRewardRule`,params)
        .then(res=>{
            resolve(res.data) 
        })
    })
 },
 // 查询客户列表-确认投放
 async confirmAdPlaceJob({commit}, params) {
    return new Promise((resolve,reject)=>{
        Request.post(`/api/adPlace/confirmAdPlaceJob`,params)
        .then(res=>{
            resolve(res.data) 
        })
    })
 },
 // 底部功能区-CPC设置
 async editAdLandmarkConfigCPC({commit}, params) {
    return new Promise((resolve,reject)=>{
        Request.post(`/api/adPlace/editAdLandmarkConfigCPC`,params)
        .then(res=>{
            resolve(res.data) 
        })
    })
 },
 // 底部功能区-CPC设置
 async editAdLandmarkConfigAward({commit}, params) {
    return new Promise((resolve,reject)=>{
        Request.post(`/api/adPlace/editAdLandmarkConfigAward`,params)
        .then(res=>{
            resolve(res.data) 
        })
    })
 },
 
 // 底部功能区-广告位收益权转让(出租)
 async setLessee({commit}, params) {
    return new Promise((resolve,reject)=>{
        Request.post(`/api/adPlace/lessee`,params)
        .then(res=>{
            resolve(res.data) 
        })
    })
 },
 // 底部功能区-取消广告位收益权转让(取消出租)
 async cancelLessee({commit}, params) {
    return new Promise((resolve,reject)=>{
        Request.post(`/api/adPlace/cancelLessee`,params)
        .then(res=>{
            resolve(res.data) 
        })
    })
 },
}

export default {
	namespaced: true,
	state,
	getters,
	mutations,
	actions
}
